# Contributor: Kyle Parisi <kyleparisi@gmail.com>
# Maintainer: Kyle Parisi <kyleparisi@gmail.com>
pkgname=zerotier-one
pkgver=1.4.6
pkgrel=1
pkgdesc="ZeroTier One allows systems to join and participate in ZeroTier virtual networks."
url="https://www.zerotier.com/"
arch="x86_64 ppc64le"
license="GPL-3.0-or-later"
makedepends="linux-headers"
subpackages="$pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/zerotier/ZeroTierOne/archive/$pkgver.tar.gz
	zerotier-one.initd
	ppc64le-make-linux.patch
	"

builddir="$srcdir"/ZeroTierOne-$pkgver
build() {
	sed -i.bak s:/bash:/sh:g ./doc/build.sh
	make
}

check() {
	make selftest
}

package() {
	make DESTDIR="$pkgdir" install
	install -m755 -D "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -d "$pkgdir"/usr/lib/modules-load.d
	echo "tun" > "$pkgdir"/usr/lib/modules-load.d/$pkgname.conf
}

sha512sums="72f00602f67190d03ac0c8caa6b79e7f346b10745bdf772c68f77a3a940cdd718d05ec642bc862a6235aab9bd3bfefb0c57571f358ae55f38761f45500f0f189  zerotier-one-1.4.6.tar.gz
a63f8e649d63a3de58a556b3adca440cd0c0d4b36239ea547d555b97852d89d0a1446f348d35e98f77faabe1fe4ffb76868b8290ad9f2b4cd8b6c599945a176c  zerotier-one.initd
fe4468a2fdcda99ab4b6055a567f12c04973ad151ad7c1f710bf4e53a5d7e1190ba864cd45274106e5b341267f24f27b2a4855bd27668fec84545d17627d79e7  ppc64le-make-linux.patch"
